/*
 * HandleRefCount.h
 *
 *  Created on: 2023年2月21日
 *      Author: terry
 */

#ifndef HANDLEREFCOUNT_H_
#define HANDLEREFCOUNT_H_

#include "BasicType.h"
#include <set>
#include <vector>
#include <mutex>


class HandleRefCount
{
public:
	typedef void*	Handle;
	typedef std::vector< void* >	HandleArray;

public:
	HandleRefCount();
	virtual ~HandleRefCount();

	bool empty();

	size_t count();

	bool exists(void* handle);

	bool add(void* handle);

	bool remove(void* handle);

	void clear();

	HandleArray getHandles();

protected:
	typedef std::set< void* >     HandleSet;

protected:
	std::mutex	m_mutex;
	HandleSet	m_handles;

};

#endif /* HANDLEREFCOUNT_H_ */
